import allure
from appium.webdriver.common.appiumby import AppiumBy

from .base import Base


class Home_page(Base):      # 首页
    # 搜索框
    __SEARCH_BOX = (AppiumBy.XPATH, '//android.widget.RelativeLayout[@resource-id="com.xueqiu.android:id/tv_banner"]')
    # 自选
    __OPTIONAL = (AppiumBy.XPATH, '//*[@resource-id="android:id/content"]/*/*[3]/*/*/*[2]')

    def goto_search(self):
        with allure.step("点击搜索框"):
            self.find_click(self.__SEARCH_BOX)
            from .search_page import Search_page
            return Search_page(self.driver)

    def goto_optional(self):
        with allure.step("自选"):
            self.find_click(self.__OPTIONAL)
            from .optional_page import Optional_page
            return Optional_page(self.driver)
